home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / IShield for Visual C++ 6.0 / DATA1.CAB / Include_Files / SDAOPTS.RUL < prev    next >
Encoding:
Text File  |  1997-11-20  |  10.2 KB  |  252 lines

  1.  
  2.  /*=======================================================================*/
  3.  /*                                                                       */
  4.  /*           (c) InstallShield Software Corporation (1996-1997)          */
  5.  /*            (c)  InstallShield Corporation  (1990-1996)                */
  6.  /*                       Schaumburg, Illinois 60173                      */
  7.  /*                          All Rights Reserved                          */
  8.  /*                           InstallShield (R)                           */
  9.  /*                                                                       */
  10.  /*   File    : sdopts.rul                                                */
  11.  /*                                                                       */
  12.  /*   Purpose : This file contains the code for the SdAskOptions          */
  13.  /*             script dialog function.                                   */
  14.  /*                                                                       */
  15.  /*=======================================================================*/
  16.  
  17.  /*------------------------------------------------------------------------*/
  18.  /*                                                                        */
  19.  /*   Function: SdAskOptions                                               */
  20.  /*                                                                        */
  21.  /*   Descrip:  This dialog will allow the user to choose different parts  */
  22.  /*             of the software to install.                                */
  23.  /*   Misc:                                                                */
  24.  /*                                                                        */
  25.  /*------------------------------------------------------------------------*/
  26. function SdAskOptions(szTitle, szMsg1, szMsg2, szDialogId, szComponents, nExclusiveFlag)
  27.           STRING  szDlg, svComponent, szTemp;
  28.           INT     nId, nReturn, nCount, nCheck, nTemp;
  29.           LIST    listComponents;
  30.           HWND    hwndDlg;
  31.           BOOL    bDone;
  32.         begin
  33.  
  34.           szDlg     = SD_DLG_ASKOPTIONS;
  35.           nSdDialog = SD_NDLG_ASKOPTIONS;
  36.  
  37.           // Check to see if user has a custom dialog, based on SdAskOptions
  38.           // if it is, modify nSdDialog to store ID of that dialog
  39.           if( szDialogId != "" ) then
  40.                if( StrToNum( nSdDialog, szDialogId ) < 0 ) then
  41.                    return -1;      // ONLY numeric Dialog ID of custom dialog
  42.                                    // supported
  43.                endif;
  44.           endif;
  45.  
  46.           // record data produced by this dialog
  47.           if (MODE=SILENTMODE) then
  48.             SdMakeName( szAppKey, szDlg, szTitle, nSdAskOptions );
  49.             SilentReadData( szAppKey, "Result", DATA_NUMBER, szTemp, nId );
  50.             if ((nId != BACK) && (nId != CANCEL)) then
  51.                SilentReadData( szAppKey, "Component", DATA_COMPONENT, szComponents, nTemp );
  52.             endif;
  53.  
  54.             return nId;
  55.           endif;
  56.  
  57.           // ensure general initialization is complete
  58.           if ( !bSdInit ) then
  59.              SdInit( );
  60.           endif;
  61.  
  62.           if (EzDefineDialog( szDlg, "", szDialogId, nSdDialog ) = DLG_ERR) then
  63.              return -1;
  64.           endif;
  65.  
  66.  
  67.           // Loop in dialog until the user selects a standard button
  68.           bDone = FALSE;
  69.  
  70.           while (!bDone)
  71.  
  72.              nId = WaitOnDialog( szDlg );
  73.  
  74.              switch (nId)
  75.              case DLG_INIT:
  76.  
  77.                   hwndDlg = CmdGetHwndDlg( szDlg );
  78.  
  79.                   // Set the correct check boxes if necessary.
  80.                   if( nExclusiveFlag = EXCLUSIVE) then
  81.                      SdOptionSetState( hwndDlg, SD_CHECK1 );
  82.                   endif;
  83.  
  84.                   SdOptionInit( szComponents, SD_CHECK1, szDlg, nExclusiveFlag, hwndDlg );
  85.  
  86.                   if(szTitle != "") then
  87.                       SetWindowText(hwndDlg, szTitle);
  88.                   endif;
  89.  
  90.                   if(szMsg1 != "") then
  91.                         SdSetStatic(szDlg, SD_STA_MSG1, szMsg1);
  92.                   endif;
  93.  
  94.                   if(szMsg2 != "") then
  95.                         SdSetStatic(szDlg, SD_STA_MSG2, szMsg2);
  96.                   endif;
  97.  
  98.                   SdGeneralInit( szDlg, hwndDlg, STYLE_BOLD, szSdProduct );
  99.  
  100.              case SD_PBUT_OK:
  101.  
  102.                   listComponents = ListCreate( STRINGLIST );
  103.                   ComponentListItems( MEDIA, szComponents, listComponents );
  104.  
  105.                   nReturn = ListSetIndex( listComponents, LISTFIRST );
  106.                   nCount = 0;
  107.                   while( nReturn != END_OF_LIST )
  108.                       ListCurrentString( listComponents, svComponent );
  109.                       ComponentSelectItem( MEDIA, svComponent, FALSE );
  110.  
  111.                       nCheck = CtrlGetState( szDlg, SD_CHECK1+nCount );
  112.                       if( nCheck = BUTTON_CHECKED ) then
  113.                           ComponentSelectItem( MEDIA, svComponent, TRUE );
  114.                       endif;
  115.  
  116.                       nReturn = ListSetIndex( listComponents, LISTNEXT );
  117.                       nCount = nCount + 1;
  118.                   endwhile;
  119.  
  120.                   ListDestroy( listComponents );
  121.  
  122.                   nId   = OK;
  123.                   bDone = TRUE;
  124.  
  125.              case BACK:
  126.                    nId    = BACK;
  127.                    bDone  = TRUE;
  128.  
  129.              case DLG_ERR:
  130.                   SdError( -1, "SdAskOptions" );
  131.                   nId   = -1;
  132.                   bDone = TRUE;
  133.  
  134.              case DLG_CLOSE:
  135.                   SdCloseDlg( hwndDlg, nId, bDone );
  136.  
  137.              default:
  138.                   // check standard handling
  139.                   if (SdIsStdButton( nId ) && SdDoStdButton( nId )) then
  140.                       bDone = TRUE;
  141.                   endif;
  142.              endswitch;
  143.  
  144.           endwhile;
  145.  
  146.           EndDialog( szDlg );
  147.           ReleaseDialog( szDlg );
  148.  
  149.           SdUnInit( );
  150.  
  151.           // record data produced by this dialog
  152.           SdMakeName( szAppKey, szDlg, szTitle, nSdAskOptions );
  153.           SilentWriteData( szAppKey, "Component", DATA_COMPONENT, szComponents, nTemp );
  154.           SilentWriteData( szAppKey, "Result", DATA_NUMBER, "", nId );
  155.  
  156.           return nId;
  157.  
  158.         end;
  159.  
  160.  /*------------------------------------------------------------------------*/
  161.  /*                                                                        */
  162.  /*   Function: SdOptionSetState                                           */
  163.  /*                                                                        */
  164.  /*   Descrip:  This funciton set the check boxes or radio button in       */
  165.  /*             SdAskOptions dialog.                                       */
  166.  /*   Misc:                                                                */
  167.  /*                                                                        */
  168.  /*------------------------------------------------------------------------*/
  169. function SdOptionSetState( hwndDlg, nControlID )
  170.           NUMBER nCount;
  171.           HWND   hwndStatic;
  172.         begin
  173.  
  174.            nCount = 0;
  175.  
  176.            hwndStatic = GetDlgItem(hwndDlg, nControlID+nCount);
  177.  
  178.            while( hwndStatic > 0 )
  179.               if( bInstall16 = TRUE ) then
  180.                   SendMessage( hwndStatic, WM_SETSTYLE, BS_AUTORADIOBUTTON, TRUE );
  181.               else
  182.                   SendMessage( hwndStatic, WM_SETSTYLE_32, BS_AUTORADIOBUTTON, TRUE );
  183.               endif;
  184.               nCount = nCount + 1;
  185.               hwndStatic = GetDlgItem(hwndDlg, nControlID+nCount);
  186.            endwhile;
  187.  
  188.         end;
  189.  
  190. /*------------------------------------------------------------------------*/
  191. /*                                                                        */
  192. /*   Function: SdOptionInit                                               */
  193. /*                                                                        */
  194. /*   Descrip:  This funciton initializes check boxes or radio button in   */
  195. /*             SdAskOptions dialog.                                       */
  196. /*   Misc:                                                                */
  197. /*                                                                        */
  198. /*------------------------------------------------------------------------*/
  199. function SdOptionInit( szComponents, nControlID, szDlg, nExclusiveFlag, hwndDlg )
  200.           STRING  svComponent[ MAX_STRING ];
  201.           NUMBER  nCount, nReturn;
  202.           HWND    hwndStatic;
  203.           LIST    listComponents;
  204.           BOOL    bSet;
  205.         begin
  206.  
  207.            bSet = FALSE;
  208.  
  209.            listComponents = ListCreate( STRINGLIST );
  210.            ComponentListItems( MEDIA, szComponents, listComponents );
  211.  
  212.            nReturn = ListSetIndex( listComponents, LISTFIRST );
  213.            nCount = 0;
  214.            while( nReturn != END_OF_LIST )
  215.                ListCurrentString( listComponents, svComponent );
  216.                hwndStatic = GetDlgItem(hwndDlg, nControlID+nCount);
  217.                if( hwndStatic ) then
  218.                    CtrlSetText( szDlg, nControlID+nCount, svComponent );
  219.  
  220.                    if(ComponentIsItemSelected( MEDIA, svComponent)) then
  221.                       if( nExclusiveFlag = EXCLUSIVE ) then
  222.                          if( bSet = FALSE ) then
  223.                            CtrlSetState( szDlg, nControlID+nCount, BUTTON_CHECKED );
  224.                          endif;
  225.                       else
  226.                          CtrlSetState( szDlg, nControlID+nCount, BUTTON_CHECKED );
  227.                      endif;
  228.                      // if first one then set as focus
  229.                      if (bSet = FALSE) then
  230.                           SetFocus( hwndStatic );
  231.                      endif;
  232.                      bSet = TRUE;
  233.                    endif;
  234.  
  235.                endif;
  236.                nReturn = ListSetIndex( listComponents, LISTNEXT );
  237.                nCount = nCount + 1;
  238.            endwhile;
  239.  
  240.            ListDestroy( listComponents );
  241.  
  242.            // Hide rest of the controls, if there is any
  243.            hwndStatic = GetDlgItem(hwndDlg, nControlID+nCount);
  244.            while ( hwndStatic )
  245.                ShowWindow( hwndStatic, WM_HIDE );
  246.                nCount = nCount + 1;
  247.                hwndStatic = GetDlgItem(hwndDlg, nControlID+nCount);
  248.            endwhile;
  249.  
  250.  
  251.         end;
  252.